﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Speech.Recognition;
using System.Windows.Forms;
using LCARSLibrary.VerbalInterface;
using System.Speech.Synthesis;

namespace LCARS_Interface
{
    public partial class Form1 : Form
    {
        //VIGrammarGroup grCommands;
        //VIGrammarGroup grActivites;
        //VIGrammarGroup grTools;
        //VIGrammarGroup grGames;

        //Grammar CreateGrCommands()
        //{
        //    GrammarBuilder grammarBuilder = new GrammarBuilder();
        //    Choices choices;


        //    choices = new Choices();


        //    GrammarBuilder subGrammarBuilder = new GrammarBuilder();
        //    Choices subChoices;

        //    subChoices = new Choices();
        //    subChoices.Add(new SemanticResultValue("Aktivitäten", 0));
        //    subGrammarBuilder.Append(subChoices);

        //    subChoices = new Choices();
        //    subChoices.Add("öffnen");
        //    subChoices.Add("anzeigen");
        //    subGrammarBuilder.Append(subChoices, 0, 1);


        //    choices.Add(subGrammarBuilder);
        //    choices.Add(new SemanticResultValue("Verbales Interface deaktivieren", 1));
        //    grammarBuilder.Append(choices);

        //    Grammar grammar = new Grammar(grammarBuilder);
        //    grammar.Name = "grCommands";

        //    return grammar;
        //}

        //Grammar CreateGrActivites()
        //{
        //    GrammarBuilder grammarBuilder = new GrammarBuilder();
        //    Choices choices;

        //    choices = new Choices();
        //    choices.Add(new SemanticResultValue("Spiele", 0));
        //    choices.Add(new SemanticResultValue("Tools", 1));
        //    grammarBuilder.Append(choices);

        //    choices = new Choices();
        //    choices.Add("öffnen");
        //    choices.Add("anzeigen");
        //    grammarBuilder.Append(choices, 0, 1);

        //    Grammar grammar = new Grammar(grammarBuilder);
        //    grammar.Name = "grActivites";

        //    return grammar;
        //}

        //Grammar CreateGrTools()
        //{
        //    GrammarBuilder grammarBuilder = new GrammarBuilder();
        //    Choices choices;

        //    choices = new Choices();
        //    choices.Add(new SemanticResultValue("Editor", 0));
        //    grammarBuilder.Append(choices);

        //    choices = new Choices();
        //    choices.Add("starten");
        //    grammarBuilder.Append(choices, 0, 1);

        //    Grammar grammar = new Grammar(grammarBuilder);
        //    grammar.Name = "grTools";

        //    return grammar;
        //}

        //Grammar CreateGrGames()
        //{
        //    GrammarBuilder grammarBuilder = new GrammarBuilder();
        //    Choices choices;

        //    choices = new Choices();
        //    choices.Add(new SemanticResultValue("Solitär", 0));
        //    choices.Add(new SemanticResultValue("Lara Croft", 1));
        //    grammarBuilder.Append(choices);

        //    choices = new Choices();
        //    choices.Add("starten");
        //    grammarBuilder.Append(choices, 0, 1);

        //    Grammar grammar = new Grammar(grammarBuilder);
        //    grammar.Name = "grGames";

        //    return grammar;
        //}


        //void VerbalInterface_CommandRecognized(object sender, RecognizedCommandArgs e)
        //{
        //    if (e.VIGrammar == null)
        //        e.NextVIGrammar = grCommands;

        //    else if (e.VIGrammar == grCommands)
        //    {
        //        if ((int)e.SemanticValue.Value == 0)
        //            e.NextVIGrammar = grActivites;
        //        else if ((int)e.SemanticValue.Value == 1)
        //        {
        //            using (SpeechSynthesizer syn = new SpeechSynthesizer())
        //            {
        //                syn.Speak("Verbale Schnittstelle wird deaktiviert.");
        //            }

        //            vi.Deactivate();
        //        }
        //    }

        //    else if (e.VIGrammar == grActivites)
        //    {
        //        if ((int)e.SemanticValue.Value == 0)
        //            e.NextVIGrammar = grGames;
        //        else if ((int)e.SemanticValue.Value == 1)
        //            e.NextVIGrammar = grTools;
        //    }
        //    else if (e.VIGrammar == grGames)
        //    {
        //        if ((int)e.SemanticValue.Value == 0)
        //        {
        //            string path = @"C:\Program Files\Microsoft Games\SpiderSolitaire\SpiderSolitaire.exe";
        //            Process process = new Process();
        //            process.StartInfo.WorkingDirectory = Path.GetDirectoryName(path);
        //            process.StartInfo.FileName = path;
        //            process.Start();
        //        }
        //    }
        //    else if (e.VIGrammar == grTools)
        //    {
        //        if ((int)e.SemanticValue.Value == 0)
        //        {
        //            string path = "notepad.exe";
        //            Process process = new Process();
        //            process.StartInfo.FileName = path;
        //            process.Start();
        //        }
        //    }
        //}

        //VerbalInterface vi;

        public Form1()
        {
            InitializeComponent();

            //grCommands = new VIGrammarGroup() { Grammar = CreateGrCommands(), ID = 0 };
            //grActivites = new VIGrammarGroup() { Grammar = CreateGrActivites(), ID = 1 };
            //grGames = new VIGrammarGroup() { Grammar = CreateGrGames(), ID = 2 };
            //grTools = new VIGrammarGroup() { Grammar = CreateGrTools(), ID = 3 };

            //List<VIGrammarGroup> viGrammars = new List<VIGrammarGroup>();
            //viGrammars.Add(grCommands);
            //viGrammars.Add(grActivites);
            //viGrammars.Add(grGames);
            //viGrammars.Add(grTools);

            //vi = new VerbalInterface(VIMode.Default);
            //vi.CommandRecognized += new EventHandler<RecognizedCommandArgs>(VerbalInterface_CommandRecognized);
            //vi.DeactivationCompleted += new EventHandler<DeactivationArgs>(vi_DeactivationCompleted);
            //vi.CommandRejected += new EventHandler<RejectedCommandArgs>(vi_CommandRejected);
            //vi.Initialize(null, viGrammars, 0);

        }

        //void vi_CommandRejected(object sender, RejectedCommandArgs e)
        //{
        //    Console.WriteLine("Command rejected.");
        //}

        //void vi_DeactivationCompleted(object sender, DeactivationArgs e)
        //{
        //    Close();
        //}

        private void button1_Click(object sender, EventArgs e)
        {
            //vi.RejectCommand();
        }
    }
}
